-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Add maxCacheKeyLength to Redis integration (remove truncation)
#18045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| describe('early returns', () => { | ||
| it.each([ | ||
| { desc: 'no args', cmd: 'get', args: [], response: 'test' }, | ||
| { desc: 'unsupported command', cmd: 'exists', args: ['key'], response: 'test' }, | ||
| { desc: 'no cache prefixes', cmd: 'get', args: ['key'], response: 'test', options: {} }, | ||
| { desc: 'non-matching prefix', cmd: 'get', args: ['key'], response: 'test', options: { cachePrefixes: ['c'] } }, | ||
| ])('should always set sentry.origin but return early when $desc', ({ cmd, args, response, options = {} }) => { | ||
| vi.clearAllMocks(); | ||
| Object.assign(_redisOptions, options); | ||
|
|
||
| cacheResponseHook(mockSpan, cmd, args, response); | ||
|
|
||
| expect(mockSpan.setAttribute).toHaveBeenCalledWith('sentry.origin', 'auto.db.otel.redis'); | ||
| expect(mockSpan.setAttributes).not.toHaveBeenCalled(); | ||
| expect(mockSpan.updateName).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some general tests for the handler, as there were none for this behavior so far.
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
| { desc: 'no cache prefixes', cmd: 'get', args: ['key'], response: 'test', options: {} }, | ||
| { desc: 'non-matching prefix', cmd: 'get', args: ['key'], response: 'test', options: { cachePrefixes: ['c'] } }, | ||
| ])('should always set sentry.origin but return early when $desc', ({ cmd, args, response, options = {} }) => { | ||
| vi.clearAllMocks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-l: Maybe it is more future proof to move this into the afterEach
chargome
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment, other than that looks good!
| span.updateName(truncate(spanDescription, 1024)); | ||
| span.updateName( | ||
| _redisOptions.maxCacheKeyLength ? truncate(spanDescription, _redisOptions.maxCacheKeyLength) : spanDescription, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a new comment here since the previous one was marked as outdated. Setting maxCacheKeyLength to 0 will result in not truncating at all, which would be unexpected IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the default behavior of our truncate function and I didn't want to do it different here. I will add a note in the JS doc of the Redis instrumentation to make it clear what passing 0 does here.
This removes the automatic truncation of the span description. Now, all cache keys are set in the description.
part of #17389